
#include <BFont>
#include <BStyle>
#include "member_BLabel.h"

using namespace BWE;

member_BLabel::member_BLabel(BLabel* label)
{
	boss = label;
	ia_align = Align_VCenter;
	ia_form = Form_None;
	dirty = true;
	imageSize.set(-1, -1);
}
member_BLabel::~member_BLabel()
{

}

void member_BLabel::freshRects()
{
	const BStyle* style = boss->realStyle();
	if (style)
		style->translate(text, t_text);
	else
		t_text.clear();
	const BFont* font = boss->font();
	if (font)
	{
		if (t_text.size())
			ia_textSize = font->textSize(t_text);
		else
			ia_textSize = font->textSize(text);
	}
	ia_imageSize = imageSize;
	if (image)
	{
		if (ia_imageSize.width() < 0)
			ia_imageSize.width() = image->width();
		if (ia_imageSize.height() < 0)
			ia_imageSize.height() = image->height();
		if (font)
		{
			if (ia_imageSize.width() < 0)
				ia_imageSize.width() = font->size();
			if (ia_imageSize.height() < 0)
				ia_imageSize.height() = font->size();
		}
	}
	const BRect& crect = boss->centerRect();
	adjust(crect);
}
